package com.css.zfzx.fxpg.common.utils.cluster;

public class Cluster {

    private MarkerClusterer markerClusterer;
    private int minClusterSize;
    public Point center;
    private Bounds gridBounds;
    public String id;
    public String name;
    public int count;

    public Cluster () {
    }

    public Cluster (MarkerClusterer markerClusterer) {
        this.markerClusterer = markerClusterer;
        this.minClusterSize = markerClusterer.minClusterSize;
        this.center = null;//落脚位置
        this.gridBounds = null;
        this.count = 0;//计数
    }

    public boolean isMarkerInClusterBounds (Marker marker) {
        return this.gridBounds.containsPoint(marker.position);
    };

    public void addMarker (Marker marker, int zoom){
        if (this.center == null){
            this.center = marker.position;
            this.updateGridBounds(zoom);//
        }
        this.count++;
        marker.isInCluster = true;
    }

    public void updateGridBounds (int zoom) {
        Bounds bounds = new Bounds(this.center, this.center);
        this.gridBounds = bounds.getExtendedBounds(this.markerClusterer.gridSize, zoom);
    }


}
